
import { Project, CreateProjectParams, UpdateProjectParams } from './project';
import { Chapter, CreateChapterParams, UpdateChapterParams } from './chapter';
import { Character, CreateCharacterParams, UpdateCharacterParams } from './character';
import {
  Conversation, Message, CreateMessageParams, CreateConversationParams,
  AIRequestParams, PromptTemplate
} from './ai-assistant';

// 直接定义基础类型，避免循环引用
interface ApiResponse<T> {
  success: boolean;
  data?: T;
  error?: string;
  message?: string;
}

interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}

/**
 * 项目API接口
 */
export interface ProjectAPI {
  getProjects(): Promise<ApiResponse<Project[]>>;
  getProject(id: string): Promise<ApiResponse<Project>>;
  createProject(params: CreateProjectParams): Promise<ApiResponse<Project>>;
  updateProject(id: string, params: UpdateProjectParams): Promise<ApiResponse<Project>>;
  deleteProject(id: string): Promise<ApiResponse<void>>;
}

/**
 * 章节API接口
 */
export interface ChapterAPI {
  getChapters(projectId: string): Promise<ApiResponse<Chapter[]>>;
  getChapter(id: string): Promise<ApiResponse<Chapter>>;
  createChapter(params: CreateChapterParams): Promise<ApiResponse<Chapter>>;
  updateChapter(id: string, params: UpdateChapterParams): Promise<ApiResponse<Chapter>>;
  deleteChapter(id: string): Promise<ApiResponse<void>>;
  reorderChapters(projectId: string, chapterIds: string[]): Promise<ApiResponse<void>>;
}

/**
 * 角色API接口
 */
export interface CharacterAPI {
  getCharacters(projectId: string): Promise<ApiResponse<Character[]>>;
  getCharacter(id: string): Promise<ApiResponse<Character>>;
  createCharacter(params: CreateCharacterParams): Promise<ApiResponse<Character>>;
  updateCharacter(id: string, params: UpdateCharacterParams): Promise<ApiResponse<Character>>;
  deleteCharacter(id: string): Promise<ApiResponse<void>>;
}

/**
 * AI助手API接口
 */
export interface AIAssistantAPI {
  getConversations(projectId: string): Promise<ApiResponse<Conversation[]>>;
  getConversation(id: string): Promise<ApiResponse<Conversation>>;
  createConversation(params: CreateConversationParams): Promise<ApiResponse<Conversation>>;
  deleteConversation(id: string): Promise<ApiResponse<void>>;
  
  getMessages(conversationId: string): Promise<ApiResponse<Message[]>>;
  createMessage(params: CreateMessageParams): Promise<ApiResponse<Message>>;
  
  getPromptTemplates(): Promise<ApiResponse<PromptTemplate[]>>;
  
  generateAIResponse(params: AIRequestParams): Promise<ApiResponse<Message>>;
} 